package com.travel.travel_springboot_web.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

public class Goods implements Serializable {
    private Long id;
    private String title;
    private String desc;
    private BigDecimal price;
    private Integer stock;
    private Integer sales;
    private Integer status;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    @JsonProperty("imageUrls")
    private List<String> imageUrls;
    @JsonProperty("cover_image")
    private String coverImage;
    @JsonProperty("giftRules")
    private List<GiftRule> giftRules;
    @JsonProperty("giftRuleText")
    private String giftRuleText;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public Integer getSales() {
        return sales;
    }

    public void setSales(Integer sales) {
        this.sales = sales;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    public LocalDateTime getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(LocalDateTime updatedAt) {
        this.updatedAt = updatedAt;
    }

    public List<String> getImageUrls() {
        return imageUrls;
    }

    public void setImageUrls(List<String> imageUrls) {
        this.imageUrls = imageUrls;
    }

    public String getCoverImage() {
        return coverImage;
    }

    public void setCoverImage(String coverImage) {
        this.coverImage = coverImage;
    }

    public List<GiftRule> getGiftRules() {
        return giftRules;
    }

    public void setGiftRules(List<GiftRule> giftRules) {
        this.giftRules = giftRules;
        if (giftRules != null && !giftRules.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            for (GiftRule rule : giftRules) {
                if (sb.length() > 0) {
                    sb.append("；");
                }
                sb.append(String.format("满%d件送%d件", rule.getBuyNum(), rule.getGiftNum()));
            }
            this.giftRuleText = sb.toString();
        } else {
            this.giftRuleText = "";
        }
    }

    public String getGiftRuleText() {
        return giftRuleText;
    }

    public void setGiftRuleText(String giftRuleText) {
        this.giftRuleText = giftRuleText;
    }
} 